import {configStore} from "@/store/config"

let storeConfig = configStore();

import axios from 'axios'
axios.defaults.withCredentials = true // 允许跨域发送 Cookie
const http = {
	get(url, params) {
		const config = {
			method: 'get',
			url,
			params
		}
		return request(config)
	},
	post(url, data) {
		const config = {
			method: 'post',
			url,
			data
		}
		return request(config)
	}
}
const request = async (config) => {
	try {
		// axios.defaults.headers.common['User-Agent'] = storeConfig.setting.bet_user_agent;

		const response = await axios(config)
		return response.data
	} catch (error) {
		console.error(error)
		return false;
		// throw error
	}
}

export default http